﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Diagnostics;

namespace CLFramework.Web
{
    /// <summary>
    /// Web程序设定
    /// </summary>
    public static class WebApplicationSettings
    {
        #region private Fileds

        private const string SettingSectionName = "asb.mes/webSettings";

        private static bool enablePopupBox;
        private static bool showGenius;
        private static WindowStyle windowStyle = WindowStyle.Window;

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes the <see cref="WebApplicationSettings"/> class.
        /// </summary>
        static WebApplicationSettings()
        {
            LoadSettings();
        }

        #endregion

        #region LoadSettings

        /// <summary>
        /// Loads the settings from application config file.
        /// </summary>
        private static void LoadSettings()
        {
            //todo logging
            //Debug.WriteLine("Begin load web settings from " + SettingSectionName);
            //ISettingList settings = ConfigurationManager.GetSection(SettingSectionName) as ISettingList;
            //if (settings != null)
            //{
            //    ISectionSettingFactory settingFactory = new SectionSettingFactory(settings);
            //    windowStyle = settingFactory.GetSectionSettingValue<WindowStyle>("windowStyle");
            //    enablePopupBox = settingFactory.GetSectionSettingValue<bool>("enablePopupBox");
            //    showGenius = settingFactory.GetSectionSettingValue<bool>("showGenius");
            //}
            //else
            //{
            //    Debug.WriteLine("No any settings can be found in application config file");
            //}
            //Debug.WriteLine("Load web settings end");
        }

        #endregion

        #region WindowStyle

        /// <summary>
        /// Gets the window style.
        /// </summary>
        /// <value>The window style.</value>
        public static WindowStyle WindowStyle
        {
            [DebuggerStepThrough]
            get { return windowStyle; }
        }

        #endregion

        #region EnablePopupBox

        /// <summary>
        /// Gets a value indicating whether enable popup box.
        /// </summary>
        /// <value><c>true</c> if enable popup box; otherwise, <c>false</c>.</value>
        public static bool EnablePopupBox
        {
            [DebuggerStepThrough]
            get { return enablePopupBox; }
        }

        #endregion

        #region ShowGenius

        /// <summary>
        /// Gets a value indicating whether show genius.
        /// </summary>
        /// <value><c>true</c> if show genius; otherwise, <c>false</c>.</value>
        public static bool ShowGenius
        {
            [DebuggerStepThrough]
            get { return showGenius; }
        }

        #endregion
    }
}
